<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/12/19
 * Time: 21:48
 */
namespace App\Services\BackendApi;

use App\Repositories\CardLogoRepository;

class CardService extends CommonService
{
    protected $cardLogoRepository;

    public function __construct(CardLogoRepository $cardLogoRepository)
    {
        parent::__construct();
        $this->cardLogoRepository = $cardLogoRepository;

    }

    public function getList($request)
    {
        $data = $this->cardLogoRepository->getCardList($request);
        return $this->responseJson(0, $data);
    }

    public function create($params)
    {
        $this->cardLogoRepository->create($params);
        return $this->responseJson(0);
    }

    public function edit($id)
    {
        if (empty($id)) {
            return $this->responseJson(422);
        }
        $data = $this->cardLogoRepository->byId($id);
        return $this->responseJson(0, $data);
    }

    public function update($id, $params)
    {
        if (empty($id)) {
            return $this->responseJson(422);
        }
        $this->cardLogoRepository->update($id, $params);
        return $this->responseJson(0);
    }

    public function delete($id)
    {
        if (empty($id)) {
            return $this->responseJson(422);
        }
        $this->cardLogoRepository->destroy($id);
        return $this->responseJson(0);
    }
}